import QtQuick 1.0
import "common"
Item {
    id:root
    width: 360
    height: 180
    property alias show : toolBar.show

    signal renameClicked(string name)
    signal removeClicked()
    signal downloadClicked()
    signal mkdirClicked(string name)
    signal clicked()

    ListModel {
        id:model
        ListElement {
            title:"rename"
            icon:"rename.png"
        }
        ListElement {
            title:"remove"
            icon:"delete.png"
        }

        ListElement {
            title:"download"
            icon:"send.png"
        }
        ListElement {
            title:"make dir"
            icon:"folder-new.png"
        }

    }

    ToolBar {
        id:toolBar
        repeater.model : model
        enabled: !removeDialog.show
        onClicked: {

            switch ( index )
            {
            case 0 : renameDialog.showDialog();break;
            case 1 : removeDialog.showDialog();break;
            case 2 : root.downloadClicked();root.clicked();break;
            case 3 : dirDialog.showDialog();break;
            }
        }
    }

    Dialog {
        id:removeDialog
        content: "Are you sure you want to remove it ? "
        onReject: show=false;
        onAccept:{
            show = false;
            root.removeClicked();
            root.clicked()

        }
    }

    InputDialog {
        id:dirDialog
        title: "Create new folder"
        onReject: show=false;
        onAccept:{
            show = false;
            root.mkdirClicked(dirDialog.text);
            root.clicked()
        }
    }

    InputDialog {
        id:renameDialog
        title: "rename file"
        onReject: show=false;
        onAccept:{
            show = false;
            root.renameClicked(renameDialog.text);
            root.clicked()
        }
    }


}
